<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
    <meta name="renderer" content="webkit">
    <link href="${pageContext.request.contextPath}/static/css/common.css" rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/bootstrap-3.3.5/css/bootstrap.min.css"
          rel="stylesheet">
    <link href="${pageContext.request.contextPath}/static/plugins/font-awesome-4.3.0/css/font-awesome.min.css"
          rel="stylesheet">

    <!--[if lt IE 9]>
    <script src="${pageContext.request.contextPath}/static/plugins/bootstrap-3.3.5/js/html5.js"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/bootstrap-3.3.5/js/respond.min.js"></script>
    <![endif]-->

    <script src="${pageContext.request.contextPath}/static/js/jquery-1.11.3.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/bootstrap-3.3.5/js/bootstrap.min.js"></script>
    <script src="${pageContext.request.contextPath}/static/plugins/layer/layer.js" type="text/javascript"></script>
    <style type="text/css">
    .lt,.col-sm-3,.col-sm-8{float:left}
		.form-group,.col-sm-2{*+overflow:hidden;}
		.form-group label{width:16%\9;*+width:16%;text-align:right\9;*+text-align:right;}
		.col-sm-8 .m-t2 {width:30%\9; *+width:36%;}
		.col-sm-8 textarea{*+width:98%;}
		.form-group .col-sm-8{width:66%\9;*+width:66%;}
		.form-group .form-control{*+width:95%;}
		.form-control{*+height:22px;}
		#sub{*+margin-right:10px;}
		.input-group .form-control{*+z-index:-1;}
		.form-group .form-control{*+line-height:22px;}
		.upload{*+position:relative;}
		.btn-primary{*+position:absolute;*+left:415px;*+top:-35px;*+z-index:3;}
		.m-t2  label{width:50px\9;*+width:50px;}
		.col-sm-8 .input-group{width:500px;lwidth:494px\9;}
		.input-group .col-md-1{width:44%;width:46%\9;*+width:38%;float:left;*+height:22px;*+line-height:22px;}
		
   
    </style>
</head>
<body>
<div class="container">
    <form class="form-horizontal m-t" method="post" action="${pageContext.request.contextPath}/admin/bannerResource_edit.action"
          enctype="multipart/form-data" id="form">
        <input type="hidden" value="${bannerResource.sid}" name="sid">
        <div class="form-group">
            <label class="col-sm-3 col-sm-3 control-label"><i class="require">*</i>资源名称:</label>
            <div class="col-sm-8">
                <input class="form-control" name="cName" size="30" value="${bannerResource.cName}"/>
            </div>
        </div>
         <div class="form-group">
            <label class="col-sm-3 control-label"><i class="require">*</i>资源类型:</label>
            <div class="col-sm-8">
                <div class="col-sm-2 m-t2">
                    <input type="radio" checked name="type" size="30" value="1"/><label>图片</label>
                </div>
                <div class="col-sm-2 m-t2">
                    <input type="radio" name="type" size="30" value="2"/><label>h5链接</label>
                </div>
            </div>
        </div>
         <div class="form-group">
            <label class="col-sm-3 control-label"><i class="require">*</i>资源是否共享:</label>
            <div class="col-sm-8">
                <div class="col-sm-2 m-t2">
                    <input type="radio" name="ifShare" size="30" value="1"/><label>共享</label>
                </div>
                <div class="col-sm-2 m-t2">
                    <input type="radio" name="ifShare" size="30" value="0"/><label>不共享</label>
                </div>
            </div>
        </div>
        <div class="form-group" id="mTypeDiv">
            <label class="col-sm-3 col-sm-3 control-label"><i class="require">*</i>上传资源:</label>
            <div class="col-sm-8">
                <div class="input-group">
                    <input class="form-control" name="content" id="content" readonly size="30"/>
                    <div class="input-group-addon upload">
                        <input class="form-control" id="upload" type="file" name="upload"
                               style="position: absolute;width: 60px;opacity: 0;"/>
                        <a class="btn btn-primary">上传</a>
                    </div>
                </div>
        <div style="margin-top: 6px;margin-bottom: 0px;font-family: 微软雅黑;font-size: 12px;color:#999999;">
            <c:if test="${sessionScope.user.rLevel != 3}">
        	*上传图片要求：尺寸为750*300，JPEG(*.JPG、*.JPEG、*.JPE)格式或是PNG格式
            </c:if> 
            <c:if test="${sessionScope.user.rLevel == 3}">
        	*上传图片要求：尺寸为750*350，JPEG(*.JPG、*.JPEG、*.JPE)格式或是PNG格式
            </c:if>        
		</div> 

                    <%-- <input class="form-control" name="content" size="30"/>--%>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 col-sm-3 control-label">URL:</label>
            <div class="col-sm-8">
                <input class="form-control" name="cUrl" id="cUrl" size="30" value="${bannerResource.cUrl}"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 col-sm-3 control-label">结算方式:</label>
            <div class="col-sm-8">
                <input class="form-control" name="settlementMethod" value="${bannerResource.settlementMethod}" size="30"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 col-sm-3 control-label">预计收益:</label>
            <div class="col-sm-8">
                <input class="form-control" name="expectedIncome" value="${bannerResource.expectedIncome}" size="30"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 col-sm-3 control-label">广告详情:</label>
            <div class="col-sm-8">
                <input class="form-control" name="adDetails" value="${bannerResource.adDetails}" size="30"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 col-sm-3 control-label">上架人:</label>
            <div class="col-sm-8">
            	<input class="form-control" name="operator" size="30" value="${bannerResource.uname}" disabled="disabled"/>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 col-sm-3 control-label">上架时间:</label>
            <div class="col-sm-8">
            	<input class="form-control" name="cTime" size="30" id="cTime" value="${bannerResource.cTime}" disabled="disabled"/>
            </div>
        </div>
       <script type="text/javascript">
           $(function () {

               $("input[name='type'][value='${bannerResource.type}']").attr("checked", true);
               $("input[name='ifShare'][value='${bannerResource.ifShare}']").attr("checked", true);
               if('${bannerResource.type}' == '2'){
            	   $("#mTypeDiv").attr("style","display:none");
               }
               $("#content").val('${bannerResource.content}'.substring('${bannerResource.content}'.lastIndexOf('/')+1));
               $("#upload").change(function () {
                   var filename = $(this).val();
                   var index = filename.lastIndexOf("\\");
                   $("input[name='content']").val(filename.substring(index + 1));
               });
           });

           function upload() {
               document.getElementById("upload").click();
           }
           
           $('input:radio[name="type"]').change( function(){
           	var selectedvalue = $("input:radio[name='type']:checked").val();
   			if (selectedvalue == 1) {
   				$("#mTypeDiv").attr("style","");
   			} else {
   				$("#mTypeDiv").attr("style","display:none");
   			}
           });
       </script>
    </form>
</div>
</body>
</html>
